#ifndef anchor_h
#define anchor_h

#include <TL\Price.h>
#include <TL\Queue_TS.h>
#include <TL\Runner.h>
#include <TL\String.h>
#include <fstream>
#include <Windows.h>
#include <WinInet.h>


class Anchor {
private:
    TL::Price m_CurrentPrice;
    HANDLE m_JSONThread;
    TL::String m_MarketURL;
    int m_RemainingPurchases;
    TL::Runner *m_Runner;
    TL::String m_SearchQuery;
    TL::Price m_TargetPrice;
    TL::Queue_TS<Anchor *> *m_TargetQueue;

private:
    Anchor(const Anchor &);
    Anchor &operator=(const Anchor &);

private:
    friend DWORD WINAPI json_thread(LPVOID thread_param);

public:
    static TL::String m_CookieString;

public:
    Anchor(TL::String search_query, TL::String target_price, int total_number_of_purchases, TL::Queue_TS<Anchor *> *target_queue);
    ~Anchor();

    const TL::String &GetMarketURL() const;
    const int &GetRemainingPurchases() const;
    const TL::String &GetSearchQuery() const;
    const TL::Price &GetTargetPrice() const;
    void Restart();
    void Stop();

    Anchor &operator++();
    Anchor &operator--();
};

#endif
